// lazy 路由懒加载
import React, { lazy } from 'react'
import { Spin } from 'antd'
// 私密路由
// import PrivateRoute from "@/routers/PrivateRoute";

// 布局排版
const Layout = lazy(() => import('@/layouts/MainLayout/index.tsx'))
// 404页面
const Null404 = lazy(() => import('@/components/404/index.tsx'))
// 首页
const Home = lazy(() => import('@/pages/teacher/Home/index.tsx'))
// 主页
const Index = lazy(() => import('@/pages/teacher/Index/index.tsx'))
// 登录页
const Login = lazy(() => import('@/pages/Login/index.tsx'))

// 懒加载  一旦调用 加载过慢  就加载antd里面的加载动画
const LoadingFun = (com: JSX.Element) => (
  <React.Suspense
    fallback={
      <div className='loading'>
        <Spin size='large' />
      </div>
    }
  >
    {com}
  </React.Suspense>
)

const routes = [
  {
    path: '/',
    element: LoadingFun(<Layout />),
    children: [
      {
        path: '/home',
        element: LoadingFun(<Home />),
      },
      {
        path: '/index',
        element: LoadingFun(<Index />),
      },
    ],
  },
  {
    path: '/login',
    element: LoadingFun(<Login />),
  },
  {
    path: '/*',
    element: LoadingFun(<Null404 />),
  },
]
export default routes
